#include "GSMainMenu.h"
#include "GSCharacterCreation.h"
#include "GSBattleMode.h"

GSMainMenu::GSMainMenu()
{
	SetStateName("GSMAINMENU");
}

GSMainMenu::~GSMainMenu()
{
	DEBUG_LOG("GSMainMenu Destroyed!");
	//SAFE_DEL(fontCustom);
}

void GSMainMenu::OnEnter()
{
	Game::GetInstance()->Reset();
	fontCustom = Game::GetDevice()->GetInstance()->getGUIEnvironment()->getFont("data/strings/mv_boli.png");
	fontCustomBig = Game::GetDevice()->GetInstance()->getGUIEnvironment()->getFont("data/strings/bigfont.png");
	mainAttrib = -1;
}

void GSMainMenu::OnExit()
{
	
}

void GSMainMenu::Update()
{
	if(DEVICE->receiver.IsKeyUp(KEY_KEY_1))
	{
		Game::SetState((GameState*)new GSCharacterCreation());
	}
	if(DEVICE->receiver.IsKeyUp(KEY_KEY_2))
	{
		Game::Exit();
	}
	//For Cheat
	if(Game::GetDevice()->receiver.IsKeyUp(KEY_KEY_Q))
	{
		Game::GetInstance()->CreatePlayer("NewPlayer", ATTRIB_PE, RANK_F);
		Game::GetInstance()->GetPlayer()->SetAttribute(ATTRIB_MATH, 100);
		Game::GetInstance()->GetPlayer()->SetAttribute(ATTRIB_PE, 100);
		Game::GetInstance()->GetPlayer()->SetAttribute(ATTRIB_SCIENCE, 100);
		Game::GetInstance()->GetPlayer()->UpdatePlayerStats();
		Game::GetInstance()->GenerateAIPlayer("ENEMY", 0, RANK_C);
		Game::SetState((GameState*)new GSBattleMode());
	}
}

void GSMainMenu::Render()
{
	Game::GetDevice()->GetDriver()->beginScene(true, true, video::SColor(255,255,255,255));

	fontCustomBig->draw("School Battle", core::rect<s32>(SCREEN_WIDTH/2 - 100, 50,100,50), video::SColor(255,255,255,255));
	fontCustom->draw("1. Start", core::rect<s32>(SCREEN_WIDTH/2 - 100, SCREEN_HEIGHT/2,100,50), video::SColor(255,0,0,0));
	fontCustom->draw("2. Exit", core::rect<s32>(SCREEN_WIDTH/2 - 100, SCREEN_HEIGHT/2 + 50,100,50), video::SColor(255,0,0,0));

	Game::GetDevice()->GetDriver()->endScene();
}